let data = String.raw`style= vue:$(!"<style" .)* _ s1:$style1 _ style:$character* _ s2:$style2 _{return {vue,style,s1,s2}}
style1="<style" _ (!">" .)+ _ ">"
style2="</style>"
character=(!"<style" !"</style>" .)
_ "whitespace"
  = [ \t\n\r]*
`

async function getStyle(txt) {
  const peggy = require("peggy")
  const parser = peggy.generate(data)
  let res = parser.parse(txt)
  const prettier = require("prettier")
  let style = await prettier.format(res.style, {
    parser: "scss"
  })
  res.style = style
  return res
}

module.exports = { getStyle }
